<?php

namespace frontend\controllers;

use Yii;
use yii\web\UploadedFile;
use frontend\components\Controller;
use frontend\models\UploadImage;

/**
 * 附件相关接口
 * AttachsController
 */
class AttachsController extends Controller {

    /**
     * Declares the allowed HTTP verbs.
     * Please refer to [[VerbFilter::actions]] on how to declare the allowed verbs.
     * @return array the allowed HTTP verbs.
     */
    protected function verbs() {
        return [
            'upload' => ['POST'],
        ];
    }

    /**
     * @inheritdoc
     */
    protected function rules() {
        return [
            [
                'allow' => true,
                'roles' => ['@'],
            ],
        ];
    }

    public function actionUpload() {
        $model = new UploadImage();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::warning('上传提交时数据未加载成功！');
        }
        $model->user_id = $this->token->user_id;
        $model->imageFile = UploadedFile::getInstanceByName('imageFile');
        return $model->upload();
    }

    public function actionRecieveAliOss() {
        
    }

}
